<?php
/*
 * Licensed this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

namespace org\boapi\ui\util;

/**
 * CreaditCardUIHelper - type with util methods for GUI based application and the UPLI.
 * <strong>Attention!</strong> Returning values are written for using with (X)HTML.
 * @author Sebastian Ritter
 * @version 1.0.0.0
 * @see org\boapi\finance\VisaCard
 * @see org\boapi\finance\MasterCard
 * @see org\boapi\finance\AmericanExpress
 * @see org\boapi\finance\DinersClub
 * @see org\boapi\finance\CarteBlanche
 * @license Apache License Version 2.0
 */
class CreditCardUIHelper {

	/**
	 * Returns input patterns for the real world of credit cards
	 * @param businessObjects
	 * @return String mask for MaskFormatter
	 * @since 1.0.0.0
	 */
    public function getMaskForBO ($businessObjectsClass) {
      if (is_a($businessObjectsClass, 'org\boapi\finance\VisaCard')) 
        return 'type="text" size ="19" maxlength="19" value="4### #### #### ####" title="Please replacing # with credit card number."';
      if (is_a($businessObjectsClass, 'org\boapi\finance\MasterCard')) 
        return 'type="text" size ="19" maxlength="19" value="5### #### #### ####" title="Please replacing # with credit card number."';
      if (is_a($businessObjectsClass, 'org\boapi\finance\AmericanExpress')) 
        return 'type="text" size ="19" maxlength="19" value="3### #### #### ####" title="Please replacing # with credit card number."';
      if (is_a($businessObjectsClass, 'org\boapi\finance\DinersClub')) 
        return 'type="text" size ="19" maxlength="19" value="3### #### #### ####" title="Please replacing # with credit card number."';
      if (is_a($businessObjectsClass, 'org\boapi\finance\CarteBlanche')) 
        return 'type="text" size ="19" maxlength="19" value="#### #### #### ####" title="Please replacing # with credit card number."';
      //default
      return 'type="text" size ="19" maxlength="19" value="###################" title="Please replacing # with credit card number."';
    }
}


/*
 * cardname                         startnumbers                        sample
 * 
 * Visa                             4                                   4111 1111 1111 1111
 * Master                           51,52,53,54,55                      5500 0000 0000 0004
 * Diner's Club                     30,36,38                            3000 0000 0000 04
 * Carte Blanche                    30,36,38                            3000 0000 0000 04
 * American Express                 34, 37                              3400 0000 0000 009
 * Discover                         6011                                6011 0000 0000 0004
 * en Route                         2014, 2149                          2014 0000 0000 009
 * JCB                              3088,3096,3112,3158,3337,3528       3088 0000 0000 0009
 * Manufacturers Hanover Trust      1033
 * Citibank                         1035, 5424
 * Chemical Bank                    1263
 * Chase Manhattan                  1665
 * Bank of America                  4024
 * Citicorp                         4128
 * New Era Bank                     4209
 * HHBC                             4302
 * Imperial Savings                 4310
 * MBNA                             4313, 6017
 * California Federal               4317
 * Wells Fargo                      5282, 5410
 * Bank of New York                 5432
 */
?>